import { ApiProperty } from '@nestjs/swagger';
import { Exclude, Expose, Transform, Type } from 'class-transformer';

class UserInfo {
  @ApiProperty({ description: '用户ID' })
  id: string;

  @ApiProperty({ description: '用户名' })
  username: string;

  @ApiProperty({ description: '用户邮箱' })
  email: string;

  @ApiProperty({ description: '用户头像URL', nullable: true })
  avatar: string | null;
}

/**
 * 任务评论响应DTO
 */
@Exclude()
export class TaskCommentResponseDto {
  @Expose()
  @ApiProperty({ description: '评论ID' })
  id: string;

  @Expose()
  @ApiProperty({ description: '评论内容' })
  content: string;

  @Expose()
  @ApiProperty({ description: '关联的任务ID' })
  taskId: string;

  @Expose()
  @ApiProperty({ description: '评论创建者ID' })
  userId: string;

  @Expose()
  @Type(() => UserInfo)
  @ApiProperty({ description: '评论创建者信息', type: UserInfo })
  user: UserInfo;

  @Expose()
  @ApiProperty({ description: '创建时间' })
  @Transform(({ value }) => value && new Date(value).toISOString())
  createdAt: Date;

  @Expose()
  @ApiProperty({ description: '更新时间' })
  @Transform(({ value }) => value && new Date(value).toISOString())
  updatedAt: Date;
} 